//
//  XS_SDWebImage.swift
//  
//
//  Created by 韩云智 on 2021/10/3.
//

import UIKit
import SDWebImage

public extension UIImage {
    
    /// 获取 GIF 图 扩展名 "gif"
    /// - Parameters:
    ///   - name: 文件名
    ///   - bundle: 默认 Bundle.main
    /// - Returns: UIImage?
    static func xsGif(_ name: String, bundle: Bundle = Bundle.main) -> UIImage? {
        guard let path = bundle.path(forResource: name, ofType: "gif"),
              let data = try? Data(contentsOf: URL(fileURLWithPath: path)) else { return nil }
        return UIImage.sd_image(withGIFData: data)
    }
}
